package com.atstudy.servlet;

import javax.servlet.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/1/29 15:20
 * @copyright: 博为峰
 */
public class AccountServlet implements Servlet {
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println("AccountServlet init");
        String name = servletConfig.getInitParameter("name");
        System.out.println("name = " + name);

        ServletContext servletContext = servletConfig.getServletContext();
        String bwf = servletContext.getInitParameter("bwf");
        System.out.println("bwf = " + bwf);
//        servletContext.getAttribute("");
//        servletContext.setAttribute("");
//        servletContext.removeAttribute();
    }

    @Override
    public ServletConfig getServletConfig() {
        return null;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("AccountServlet service");
        String name = servletRequest.getParameter("name");
        System.out.println("name = " + name);

        PrintWriter pw = servletResponse.getWriter();
        pw.write("<h1>com.atstudy</h1>");
    }

    @Override
    public String getServletInfo() {
        return null;
    }

    @Override
    public void destroy() {
        System.out.println("AccountServlet destroy");
    }
}
